package com.centling;

import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Controller;

/**
 * Created by centling on 2017/4/12.
 */
@Controller
public class WsController
{
    @MessageMapping("/welcome")
    @SendTo("/topic/getResponse")//@SendTo注解表示当服务器有消息需要推送的时候，
                                 // 会对订阅了@SendTo中路径的浏览器发送消息。
    public ReponseMessage say(RequestMessage message)
    {
        System.out.println(message.getName());
        return new ReponseMessage("welcome,"+message.getName()+"!");
    }
}
